﻿using AbpEntityFrameworkcore.DbContext;
using AbpToDomain.EntityInfo;
using AbpToDomain.View;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpApplication.Expand
{
    public class QueryDynamic_View_NeetOutMaterial
    {

        private readonly MyDbContext context;

        public QueryDynamic_View_NeetOutMaterial(MyDbContext context)
        {
            this.context = context;
        }

        public List<View_NeetOutMaterial> QueryDynameic(string MaterialName,       
        string MaterialCode,  string? Batch, string BoxGridCode, string? OrderNo)
        {
            IQueryable<View_NeetOutMaterial> View_NeetOutMaterials = context.View_NeetOutMaterials;
            if (!string.IsNullOrEmpty(MaterialName))
            {
                View_NeetOutMaterials = View_NeetOutMaterials.Where(b => b.MaterialName.Contains(MaterialName));
            }
            if (!string.IsNullOrEmpty(MaterialCode))
            {
                View_NeetOutMaterials = View_NeetOutMaterials.Where(b => b.MaterialCode.Contains(MaterialCode));
            }
            if (!string.IsNullOrEmpty(Batch))
            {
                View_NeetOutMaterials = View_NeetOutMaterials.Where(b => b.Batch.Contains(Batch));
            }
            if (!string.IsNullOrEmpty(BoxGridCode))
            {
                View_NeetOutMaterials = View_NeetOutMaterials.Where(b => b.BoxGridCode.Contains(BoxGridCode));
            }
            if (!string.IsNullOrEmpty(OrderNo))
            {
                View_NeetOutMaterials = View_NeetOutMaterials.Where(b => b.OrderNo.Contains(OrderNo));
            }
            return View_NeetOutMaterials.ToList();
        }

    }
}
